# gazelle:prefix github.com/jetstack/cert-manager
# gazelle:proto disable_global
# gazelle:exclude docs/generated/reference/generate/json_swagger

load("@io_bazel_rules_docker//container:container.bzl", "container_bundle")
load("@io_bazel_rules_docker//contrib:push-all.bzl", "docker_push")

# export WORKSPACE so workspace_binary rules can be used outside the root
exports_files([
    "WORKSPACE",
    "LICENSE",
    "LICENSES",
    "go.mod",
    "go.sum",
])

genrule(
    name = "save_docker_version",
    outs = ["version"],
    cmd = "grep '^STABLE_DOCKER_TAG ' bazel-out/stable-status.txt | awk '{print $$2}' >$@",
    stamp = 1,
    visibility = ["//visibility:public"],
)

container_bundle(
    name = "images",
    images = {
        "{STABLE_DOCKER_REGISTRY}/cert-manager-controller:{STABLE_DOCKER_TAG}": "//build:controller.image",
        "{STABLE_DOCKER_REGISTRY}/cert-manager-acmesolver:{STABLE_DOCKER_TAG}": "//build:acmesolver.image",
        "{STABLE_DOCKER_REGISTRY}/cert-manager-webhook:{STABLE_DOCKER_TAG}": "//build:webhook.image",
        "{STABLE_DOCKER_REGISTRY}/cert-manager-cainjector:{STABLE_DOCKER_TAG}": "//build:cainjector.image",
        "{STABLE_DOCKER_REGISTRY}/cert-manager-ctl:{STABLE_DOCKER_TAG}": "//build:ctl.image",
    },
    tags = ["manual"],
)

docker_push(
    name = "images.push",
    bundle = ":images",
    tags = ["manual"],
)

filegroup(
    name = "package-srcs",
    srcs = glob(
        ["**"],
        exclude = [
            "bazel-*/**",
            ".git/**",
        ],
    ),
    visibility = ["//visibility:private"],
)

filegroup(
    name = "all-srcs",
    srcs = [
        ":package-srcs",
        "//build:all-srcs",
        "//cmd/acmesolver:all-srcs",
        "//cmd/cainjector:all-srcs",
        "//cmd/controller:all-srcs",
        "//cmd/ctl:all-srcs",
        "//cmd/util:all-srcs",
        "//cmd/webhook:all-srcs",
        "//deploy:all-srcs",
        "//devel:all-srcs",
        "//hack:all-srcs",
        "//internal:all-srcs",
        "//pkg/acme:all-srcs",
        "//pkg/api:all-srcs",
        "//pkg/apis:all-srcs",
        "//pkg/client/clientset/versioned:all-srcs",
        "//pkg/client/informers/externalversions:all-srcs",
        "//pkg/client/listers/acme/v1:all-srcs",
        "//pkg/client/listers/acme/v1alpha2:all-srcs",
        "//pkg/client/listers/acme/v1alpha3:all-srcs",
        "//pkg/client/listers/acme/v1beta1:all-srcs",
        "//pkg/client/listers/certmanager/v1:all-srcs",
        "//pkg/client/listers/certmanager/v1alpha2:all-srcs",
        "//pkg/client/listers/certmanager/v1alpha3:all-srcs",
        "//pkg/client/listers/certmanager/v1beta1:all-srcs",
        "//pkg/controller:all-srcs",
        "//pkg/ctl:all-srcs",
        "//pkg/feature:all-srcs",
        "//pkg/issuer:all-srcs",
        "//pkg/logs:all-srcs",
        "//pkg/metrics:all-srcs",
        "//pkg/scheduler:all-srcs",
        "//pkg/util:all-srcs",
        "//pkg/webhook:all-srcs",
        "//test/acme/dns:all-srcs",
        "//test/e2e:all-srcs",
        "//test/integration:all-srcs",
        "//test/internal/apiserver:all-srcs",
        "//test/internal/util:all-srcs",
        "//test/unit/coreclients:all-srcs",
        "//test/unit/discovery:all-srcs",
        "//test/unit/gen:all-srcs",
        "//test/unit/listers:all-srcs",
        "//tools/cobra:all-srcs",
    ],
    tags = ["automanaged"],
    visibility = ["//visibility:public"],
)
